package com.xcity.game.item;

import com.xcity.game.item.effect.AddBuffEffect;
import com.xcity.game.item.effect.AddCharmEffect;
import com.xcity.game.item.effect.AddEmployeeEffect;
import com.xcity.game.item.effect.AddEmployeeExpEffect;
import com.xcity.game.item.effect.AddExpEffect;
import com.xcity.game.item.effect.AddFriendIntimacyEffect;
import com.xcity.game.item.effect.AddGoldEffect;
import com.xcity.game.item.effect.AddGroupBuyCouponNumEffect;
import com.xcity.game.item.effect.AddHonorEffect;
import com.xcity.game.item.effect.AddItemEffect;
import com.xcity.game.item.effect.AddKingCoinEffect;
import com.xcity.game.item.effect.AddPetEffect;
import com.xcity.game.item.effect.AddPetSpiritEffect;
import com.xcity.game.item.effect.AddSkillPointsEffect;
import com.xcity.game.item.effect.AddStoneEffect;
import com.xcity.game.item.effect.AddStrengthEffect;
import com.xcity.game.item.effect.AddVigourEffect;
import com.xcity.game.item.effect.AvoidInvadeEffect;
import com.xcity.game.item.effect.DropEmployeeByQualityEffect;
import com.xcity.game.item.effect.DropEquipmentEffect;
import com.xcity.game.item.effect.ExtendWorldEventTimeEffect;
import com.xcity.game.item.effect.GetDropGroupItemEffect;
import com.xcity.game.item.effect.GetSkillEffect;
import com.xcity.game.item.effect.LoseGoldEffect;
import com.xcity.game.item.effect.NoneEffect;
import com.xcity.game.item.effect.RemoveWorldEventEffect;
import com.xcity.game.item.effect.SafeBoxEffect;
import com.xcity.game.item.effect.ShieldEffect;

import gnu.trove.map.TIntObjectMap;
import gnu.trove.map.hash.TIntObjectHashMap;

public class ItemEffectFactory {

	static enum EFFECT {
		ADD_BUFF(ItemEffect.ADD_BUFF, new AddBuffEffect()),
		ADD_GOLD(ItemEffect.ADD_GOLD, new AddGoldEffect()),
		ADD_STONE(ItemEffect.ADD_STONE, new AddStoneEffect()),
		ADD_ITEM(ItemEffect.ADD_ITEM, new AddItemEffect()),
		LOSE_GOLD(ItemEffect.LOSE_GOLD, new LoseGoldEffect()),
		REMOVE_WORLD_EVENT(ItemEffect.REMOVE_WORLD_EVENT, new RemoveWorldEventEffect()),
		EXTEND_WORLD_EVENT_TIME(ItemEffect.EXTEND_WORLD_EVENT_TIME, new ExtendWorldEventTimeEffect()),
		ADD_EXP(ItemEffect.ADD_EXP, new AddExpEffect()),
		GET_PET(ItemEffect.GET_PET, new AddPetEffect()),
		ADD_PET_SPIRIT(ItemEffect.ADD_PET_SPIRIT, new AddPetSpiritEffect()),
		DROP_EMPLOYEE_BY_QUALITY(ItemEffect.DROP_EMPLOYEE, new DropEmployeeByQualityEffect()),
		GET_DROP_GROUP_ITEM(ItemEffect.GET_DROP_GROUP_ITEM, new GetDropGroupItemEffect()),
		ADD_STRENGTH(ItemEffect.ADD_STRENGTH, new AddStrengthEffect()),
		ADD_FRIEND_INTIMACY(ItemEffect.ADD_FRIEND_INTIMACY, new AddFriendIntimacyEffect()),
		ADD_CHARM(ItemEffect.ADD_CHARM, new AddCharmEffect()),
		ADD_EMPLOYEE(ItemEffect.ADD_EMPLOYEE, new AddEmployeeEffect()),
		DROP_EQUIPMENT(ItemEffect.DROP_EQUIPMENT, new DropEquipmentEffect()),
		GET_SKILL(ItemEffect.GET_SKILL, new GetSkillEffect()),
		PRESENT_PUZZLE_CHIPS_TO_FRIEND(ItemEffect.PRESENT_PUZZLE_CHIPS_TO_FRIEND, new NoneEffect()),
		SAFE_BOX(ItemEffect.SAFE_BOX, new SafeBoxEffect()),
		SHIELD(ItemEffect.SHIELD, new ShieldEffect()),
		AVOID_INVADE(ItemEffect.AVOID_INVADE, new AvoidInvadeEffect()),
		ADD_EMPLOYEE_EXP_IMMEDIATELY(ItemEffect.ADD_EMPLOYEE_EXP_IMMEDIATELY, new AddEmployeeExpEffect()),
		ADD_VIGOUR(ItemEffect.ADD_VIGOUR, new AddVigourEffect()),
		ADD_SKILL_POINTS(ItemEffect.ADD_SKILL_POINTS, new AddSkillPointsEffect()),
		ADD_KING_COIN(ItemEffect.ADD_KING_COIN, new AddKingCoinEffect()),
		ADD_HONOR(ItemEffect.ADD_HONOR, new AddHonorEffect()),
		ADD_GROUP_BUY_COUPON_NUM(ItemEffect.ADD_GROUP_BUY_COUPON_NUM, new AddGroupBuyCouponNumEffect()),
		;
		final int effectId;
		final ItemEffect effect;
		EFFECT(int effectId, ItemEffect effect) {
			this.effectId = effectId;
			this.effect = effect;
		}
	}
	
	private static TIntObjectMap<ItemEffect> effects = new TIntObjectHashMap<ItemEffect>();
	static {
		EFFECT[] vals = EFFECT.values();
		for (EFFECT val : vals) {
			effects.put(val.effectId, val.effect);
		}
	}
	
	public static ItemEffect create(GameItem item) {
		return create(item.getTemplate());
	}
	
	public static ItemEffect create(ItemTemplate template) {
		return create(template.getEffect());
	}
	
	public static ItemEffect create(int effectId) {
		return effects.get(effectId);
	}
	
}
